/**
 * Company : Thai Informatic System Co., Ltd.
 * Created By : Dr.Tree
 * Created On : Feb 13, 2012  9:56:14 PM 
 * e-Mail : chatree@tis.co.th
 * Mobile Phone : (+66) 087-921-5115
 * Package Name : jpa.service.promis.common
 * File Name : SessionEntityManager.java
 * TODO
 */
package jpa.service.promis.common;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 * @author chatree
 *
 */
public class SessionEntityManager {
	
	private EntityManagerFactory emf = null;
	private EntityManager em  = null;
	
	public EntityManager CreatedEntityManager() throws Exception {
		if(emf == null)
			emf = Persistence.createEntityManagerFactory("PROMIS");
		if(em == null)
			em = emf.createEntityManager();
		
		return em;
	}
	
	public EntityManagerFactory XcreateEntityManagerFactory() throws Exception {
		
		if(emf == null)
			emf = Persistence.createEntityManagerFactory("PROMIS");
		
		return emf;
	}
}
